﻿namespace LitTools
{
    /// <summary>
    /// 消息管理拓展
    /// </summary>
    public static class MessageManagerExt
    {
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="sync"></param>
        public static void SendMessage(this IMessageObj obj, bool sync = false)
        {
            MessageManager.Instance.BoradcastMessage(obj, sync);
        }
        /// <summary>
        /// 监听消息
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="act"></param>
        public static void RegisterMessage(this IMessageObj obj
            , MessageManager.MessageAct act)
        {
            MessageManager.Instance.RegisterMessage(obj.MessageId, act);
        }
        /// <summary>
        /// 取消监听
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="act"></param>
        public static void UnregisterMessage(this IMessageObj obj
        , MessageManager.MessageAct act)
        {
            MessageManager.Instance.UnregisterMessage(obj.MessageId, act);
        }
    }
}